<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <script src="vue.js"></script>
</head>

<body>
    <div id="root">
        <img :src=picture alt="" width="200px"><br />
        <button @click="changePic">点我切换图片</button>

    </div>

    <script>

        Vue.config.productionTip = false;
        const vm = new Vue({
            el: '#root',
            data: {
                pic: true,
                x: "images/1.png",
                u: "images/2.png",
            },
            computed: {
                picture() {
                    return this.pic ? this.x : this.u
                }
            },
            methods: {
                changePic() {
                    this.pic = !this.pic
                }
            },
        })
    </script>
</body>

</html>